/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package at.tugraz.hidipic.model;

import java.io.Serializable;
import java.util.Set;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import org.hibernate.validator.constraints.Length;

/**
 *
 * @author mario
 */
@Entity
@Table(name = "method")
public class Method implements Serializable {

    @Id
    @Length(min = 2, max = 30, message = "{methodname.length}")
    @Pattern(regexp = "[a-zA-Z0-9]+", message = "{methodname.regexp}")
    @NotNull
    private String name;
    @Length(min = 2, max = 30, message = "{methodname.length}")
    @Pattern(regexp = "[a-zA-Z0-9 _-]+", message = "{methodname.regexp}")
    @NotNull
    private String showName;
    @OneToMany(mappedBy = "method")
    private Set<Result> results;
    @Column(columnDefinition="text")
    @NotNull
    private String description;

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getShowName() {
        return showName;
    }

    public void setShowName(String showName) {
        this.showName = showName;
    }

    public Set<Result> getResults() {
        return results;
    }

    public void setResults(Set<Result> results) {
        this.results = results;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof Method) {
            return this.name.equals(((Method) obj).getName());
        } else {
            return false;
        }
    }

    @Override
    public int hashCode() {
        return this.name.hashCode();
    }
}
